package net.yussi.component.chart.pie3D
{
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	import mx.core.UIComponent;

	public class PieLabel extends UIComponent
	{
		private var _txt:TextField = new TextField; 
		public var data:Object;
		
		public function PieLabel()
		{
			super();
		}
		
		override protected function createChildren():void
	    {
	    	super.createChildren();
	    	
	    	_txt.selectable = false;
	    	_txt.wordWrap = false;
	    	_txt.autoSize=TextFieldAutoSize.LEFT;
	    	this.addChild(_txt);
	    }
		
		public function setText(text:String, align:String="left"):void{
			_txt.text = text;
			
			switch(align)
			{
				case "right":
					_txt.x = -_txt.textWidth - 4;
					break;
				case "left":
					_txt.x = 0;
					break;  
			}
			_txt.y = -(_txt.textHeight/2) - 2;
		}

		public function get textWidth():Number
		{
			return _txt.textWidth;
		}
	}
}